home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / fix < prev    next >
Text File  |  1994-02-21  |  646b  |  25 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. //  Syntax:  fix ( X )
  4.  
  5. //  Description:
  6.  
  7. //  Fix rounds the elements of X to the nearest integer towards zero.
  8.  
  9. //  See Also ceil, floor, round, sign, abs
  10.  
  11. //-------------------------------------------------------------------//
  12.  
  13. fix = function ( X )
  14. {
  15.   if (X.type == "real")
  16.   {
  17.     return sign (X) .* floor (abs (X));
  18.   else if (X.type == "complex") {
  19.     return (sign (real (X)) .* floor (abs (real (X)))) + ...
  20.            ((0+1j)*(sign (imag (X))) .* floor (abs (imag (X))));
  21.   else
  22.     error("fix() only takes real or complex (scalar and matrix) arguments");
  23.   }}
  24. };
  25.